home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games: Greatest Hits 1996
/
Amiga Games: Greatest Hits 1996.iso
/
rexx
/
checkword.epxx
< prev
next >
Wrap
Text File
|
1996-07-28
|
4KB
|
140 lines
/************************************************************************/
/* */
/* File : CheckWord.epxx */
/* Author : Martin Reddy */
/* Date : 28/8/92 */
/* Purpose : An ARexx script used to control the text editor EdWord */
/* Note : This is part of the Spell Checking facility of EdWord */
/* Function : This script prompts the user for a string and then checks */
/* to see if this string is in the dictionary. The user is */
/* informed of the result and, if the word was not found, */
/* then upto 4 possible suggestions are made. */
/* Updates : [28/7/96] - Check for no word, ignore valid roots, add */
/* word to dictionary, edit word in-situ */
/* */
/************************************************************************/
/* Set IGNORE_VALID_ROOTS to TRUE if you want the spell check to
ignore words which aren't in the dictionary, but do have a
valid root, e.g. ignore WASTED if the word WASTE exists in the
dictionary. This reduces the need to have every tense of a
word, and plurals, to be explicitly stored in the dictionary */
IGNORE_VALID_ROOTS = TRUE
/*-------------- Nothing To Change Below Here -----------*/
HOST = ADDRESS()
ADDRESS VALUE HOST
OPTIONS RESULTS
/********** Make sure that the ISpell process is up *********/
IF ~SHOW( PORTS, 'IRexxSpell' ) THEN DO
Message "Loading Dictionary..."
ADDRESS COMMAND 'run <nil: >nil: EdSpell:ISpell/ispell -r >nil: <nil:'
ADDRESS COMMAND 'EdSpell:ISpell/WaitForPort IRexxSpell'
IF RC ~= 0 THEN DO
Inform "Could Not Start ISpell Process|Spell Check Aborted!"
CALL MyExit
END
END
/**************** Get a Word From The User *****************/
Message "Spell Checking Current Word..."
GetWord
THEWORD = RESULT
SEARCHWORD = COMPRESS( UPPER(THEWORD), '~`,./<>?;:"[]{}!@#$%^&*()+|=\- ' )
If ( SEARCHWORD == '' ) | ( THEWORD == 'RESULT' ) THEN DO
Inform "No Word Under Cursor"
CALL MyExit
END
/**************** Now check the word ****************/
REPEAT_CHECK = TRUE
FIRST_CHECK = TRUE
DO UNTIL REPEAT_CHECK = FALSE
REPEAT_CHECK = FALSE
ADDRESS "IRexxSpell" CHECK SEARCHWORD
WORD = RESULT
IF ( WORD == "*" ) | ( (LEFT(WORD,1) == "+") & (IGNORE_VALID_ROOTS == TRUE) ) THEN DO
IF FIRST_CHECK == TRUE THEN DO
Inform SEARCHWORD" Found In Dictionary|Word Is Spelt Correctly"
END
CALL MyExit
END; ELSE IF LEFT(WORD,1) == "+" THEN DO
PARSE VAR WORD DUMMY ROOT
Choice SEARCHWORD" Is A Valid Combination|But Is Not In Dictionary|(Root Word Is "||COMPRESS(ROOT,' ')||")@@Okay|Edit|Add"
END; ELSE IF LEFT(WORD,1) == "&" THEN DO
PARSE VAR WORD DUMMY SUGA SUGB SUGC SUGD SUGE
SUG = "|1) "SUGA
IF (SUGB ~= "END") & (SUGB ~= "") & (SUGB ~= "SUGB") THEN DO
SUG = SUG||"|2) "||SUGB
END
IF (SUGC ~= "END") & (SUGC ~= "") & (SUGC ~= "SUGC") THEN DO
SUG = SUG||"|3) "||SUGC
END
IF (SUGD ~= "END") & (SUGD ~= "") & (SUGD ~= "SUGD") THEN DO
SUG = SUG||"|4) "||SUGD
END
Choice SEARCHWORD" Not In Dictionary|Possible Suggestions Are:|"||SUG||"@@Okay|Edit|Add"
END; ELSE DO
Inform SEARCHWORD" Not In Dictionary|No Possible Suggestions Found"
CALL MyExit
END
IF RC == 0 THEN DO
CALL AddWord( SEARCHWORD )
END; ELSE IF RC == 2 THEN DO
CALL EditWord
REPEAT_CHECK = TRUE
Message "Spell Checking New Replacement..."
END
FIRST_CHECK = FALSE
END
CALL MyExit
/************ PROCEDURE: "AddWord(word)" ************/
AddWord: PROCEDURE
PARSE ARG THEWORD
Choice "Please Confirm The Addition of|"||THEWORD||" To The Dictionary.@@Add Word|Cancel"
IF RC ~= 0 THEN DO
ADDRESS "IRexxSpell" ADD THEWORD
END
RETURN
/************ PROCEDURE: "EditWord()" ************/
EditWord: PROCEDURE EXPOSE SEARCHWORD
GetInput "Type New Spelling For Word (Blank=Abort)"
NEWWORD = RESULT
IF ( NEWWORD == "RESULT" ) | ( NEWWORD == "" ) THEN CALL MyExit
DeleteWord
InsertText D2C(34)||NEWWORD||" "||D2C(34)
MovePrevWord
SEARCHWORD = UPPER( NEWWORD )
RETURN
/************ PROCEDURE: "MyExit()" ************/
MyExit: PROCEDURE
Message ""
EXIT
RETURN